const store = {
    auth:{
        token:localStorage.getItem('user-token') || null,
        info:JSON.parse(localStorage.getItem('user-info')) || null
    },
    event_search_history:JSON.parse(localStorage.getItem('event_search_history')) || [],
    set_auth(user){
        this.auth.token = user.token;
        this.auth.info = user;

        localStorage.setItem('user-token',this.auth.token);
        localStorage.setItem('user-info',JSON.stringify(this.auth.info));
    },
    is_auth(){
        return this.auth.token && this.auth.info;
    },
    remove_auth(user) {
        this.auth.info = null;
        this.auth.token = null;
        localStorage.removeItem('user-info');
        localStorage.removeItem('user-token');
    },
    set_event_search_history(event_code){
        let event_search_history = this.event_search_history;
        event_search_history.push(event_code);
        this.event_search_history = event_search_history.splice(-3,3);
        localStorage.setItem('event_search_history',JSON.stringify(this.event_search_history));
    }
};